<template>
  <table-layout :haveSider="false" :isStandTable="false">
    <template #headCustom>
      <a-button type="primary" @click="unSubmit">返回</a-button>
      <!-- <a-button type="primary" style="marginLeft:20px" @click="onSure">确认</a-button> -->
      <!-- <a-button type="primary" style="marginLeft:20px" @click="onReset">重置</a-button> -->
    </template>
    <template #form>
      <div class="stepsbox">
        <div class="stepsbox1">
          <a-steps class="steps" :current="current">
            <a-step v-for="item in steps" :key="item.title" :title="item.title" />
          </a-steps>
        </div>
        
        <div class="stepsbox2"  v-show="current==0">
          <step1 @nextStep="nextStep"  ></step1>
        </div>
        <div class="stepsbox2"  v-show="current==1">
          <step2 @onSubmit="onSubmit" @onCancel="previous"  :zzid="zzid"></step2>
        </div>
      </div>
    </template>
  </table-layout>
</template>

<script>
import tableLayout from '@/views/app/biz/common/index'
import basicForm from '../common/basicForm'
import step1 from './step1.vue'
import step2 from './step2.vue'
import {deleteInfo } from './companyLicense'

export default {
  components: {
    tableLayout,
    basicForm,
    step1,
    step2,
  },
  data() {
    return {
      loading: false,
      modal: {
        modalVisible: false,
        modalTitle: '新增企业证照',
        modalWidth: '1000px',
      },
      current: 0,
      steps: [
        {
          title: '基本信息',
          isSubmit: false,
        },
        {
          title: '上传证照',
          isSubmit: false,
        },
      ],
      zzid:{
        pid:'',
        zhengZhaotpPid:'',
        sysSeq:'',
        zhengZhaolx:''
      }

    }
  },
  computed: {},
  mounted() {
    this.backPathName = this.$route.params.pathName ? this.$route.params.pathName : 'companyLicense'
    if (this.$route.params.pid) {
        this.editModal(this.$route.params.pid)
    }else{
        this.addModal()
    }
  },
  methods: {
    onBack() {
      this.$router.push({
        name: this.backPathName,
        params: {
          isJump: false,
          pathName: this.$route.name,
          iscloseMul:true,
        }
      })
    },
    // 新增按钮 点击了新增
    addModal() {
      console.log('点击了新增')
    },
    nextStep(zzid){
      if(zzid){
        this.zzid=zzid;
      }
      this.current++
    },
    previous(){
      this.current--
    },
    onSubmit(){
      this.onBack()
    },
    unSubmit(){//中途关闭，此处添加删除未上传完的证照信息
      console.log(this.zzid.pid);
      if(this.zzid.pid){
        this.deleteInfo()
      }else{
        this.$message.warning({ content: '信息填写未完成', duration: 3 })
        this.onBack()
      }
    },
    async deleteInfo(val) {
      // this.$message.loading({ content: '提交中'， })
      let res = await deleteInfo(this.zzid)
      console.log(res)
      if (res && res.code && res.code === 'C1' && res.data) {
        this.$message.warning({ content: '信息填写未完成', duration: 3 })
        this.onBack()
      }
    },
    
  },
}
</script>

<style scoped>
.stepsbox{
  height: 100%;
  display: flex;
  flex-direction: column;
}
.stepsbox1{
  height: 100px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.stepsbox2{
  overflow-y: scroll;
}

.steps{
  width: 80%;
  margin: 0 auto;
}
</style>